﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sldg="http://schemas.xceed.com/silverlight/xaml/datagrid"
                    xmlns:s="clr-namespace:System;assembly=mscorlib">

   <!--**************************
    * TEMPLATE: Row
    ************************** -->
   <ControlTemplate x:Key="rowTemplate"
                    TargetType="sldg:Row">
      <Grid x:Name="rootGrid">
         <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
               <VisualState x:Name="Normal" />
               <VisualState x:Name="MouseOver" />
               <VisualState x:Name="MouseOverSelected" />
               <VisualState x:Name="Selected" />
            </VisualStateGroup>

            <VisualStateGroup x:Name="CurrentStates">
               <VisualState x:Name="Current" />
               <VisualState x:Name="NotCurrent" />
            </VisualStateGroup>
         </VisualStateManager.VisualStateGroups>

         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>

         <!-- The border responsible for the visual outline of the row (gridlines and background)
              spans the GroupLevelIndicatorPane and ChildrenHost Panel. Those 2 elements are not children of
              the Border because we don't want the border to be displayed in the GroupLevelIndicatorPane. -->

         <Border x:Name="rootBorder"
                 Grid.Column="0"
                 Grid.ColumnSpan="2"
                 Background="{TemplateBinding Background}"
                 BorderBrush="{TemplateBinding BorderBrush}"
                 BorderThickness="{TemplateBinding BorderThickness}"
                 Padding="{TemplateBinding Padding}" />

         <sldg:ColumnElementsHost x:Name="CellsHost"
                             Grid.Column="1"
                             Margin="{TemplateBinding BorderThickness}"
                             HorizontalAlignment="Stretch"
                             VerticalAlignment="Stretch"/>
            <!-- The PART_CellsHost part designates the Panel to which this Row's Cells should be added.-->
         <!--<sldg:CellsPanel x:Name="CellsHost"
                          Grid.Column="1"
                          Margin="{TemplateBinding BorderThickness}"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch" />-->
      </Grid>
   </ControlTemplate>

   <!--**************************
    * TEMPLATE: Cell
    ************************** -->
   <ControlTemplate x:Key="cellTemplate"
                    TargetType="sldg:Cell">

      <Grid x:Name="CellVisual">
         <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
               <VisualState x:Name="Normal" />
               <VisualState x:Name="MouseOver" />
               <VisualState x:Name="Pressed" />
               <VisualState x:Name="Dragged" />
            </VisualStateGroup>

            <VisualStateGroup x:Name="CurrentStates">
               <VisualState x:Name="NotCurrent" />
               <VisualState x:Name="Current" />
            </VisualStateGroup>

         </VisualStateManager.VisualStateGroups>

         <Grid x:Name="DragContentHost">
            <Border x:Name="mainBorder"
                    Padding="{TemplateBinding Padding}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    Background="{TemplateBinding Background}"
                    BorderThickness="1">

                    <ContentControl x:Name="CellContentHost"
                                    DataContext="{TemplateBinding Content}"
                                    Content="{TemplateBinding Content}"
                                    HorizontalAlignment="Stretch"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"/>
                    <!--<sldg:CellContentHost x:Name="CellContentHost"
                                     HorizontalAlignment="Stretch" />-->

            </Border>
         </Grid>
      </Grid>

   </ControlTemplate>

   <!--**************************
    * STYLE: Row
    ************************** -->
   <Style TargetType="sldg:Row">

      <Setter Property="Background"
              Value="#60FFFFFF" />

      <Setter Property="BorderBrush"
              Value="Black" />

      <Setter Property="BorderThickness"
              Value="0,0,0,1" />

      <Setter Property="Template"
              Value="{StaticResource rowTemplate}" />

   </Style>

   <!--**************************
    * STYLE: Cell
    ************************** -->
   <Style TargetType="sldg:Cell">
      <!-- Set the Cell's background to Transparent to make it hit-testable
           while preserving the background drawn by the underlying Row. -->
      <Setter Property="Background"
              Value="Transparent" />

      <Setter Property="BorderBrush"
              Value="Transparent" />

      <Setter Property="Template"
              Value="{StaticResource cellTemplate}" />

   </Style>

</ResourceDictionary>
